/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aeronef.appStates;

import com.jme3.app.Application;
import com.jme3.app.state.AppStateManager;
import com.jme3.niftygui.NiftyJmeDisplay;
import de.lessvoid.nifty.Nifty;
import aeronef.control.screen.HostLobbyScreen;
import aeronef.control.screen.StartScreen;
import java.util.Collection;

/**
 *
 * @author Hagan
 */
public class MenuState extends BasicAppState {
    
    NiftyJmeDisplay niftyDisplay;
    Nifty nifty;
    
    @Override
    public void initialize(AppStateManager stateManager, Application app) {
        
        super.initialize(stateManager, app);
        
        inputManager.setCursorVisible(true);
        
        niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
        nifty = niftyDisplay.getNifty();
        guiViewPort.addProcessor(niftyDisplay);
        
        goToStartScreen();
    }

    public void goToStartScreen() {
        removeAllScreens();
        StartScreen startScreen = new StartScreen();
        startScreen.initialize(stateManager, app);
        nifty.fromXml("Interface/start_menu.xml", "start", startScreen);
    }
    
    public void goToHostLobbyScreen() {
        removeAllScreens();
        HostLobbyScreen hostLobbyScreen = new HostLobbyScreen();
        hostLobbyScreen.initialize(stateManager, app);
        nifty.fromXml("Interface/host_lobby.xml", "host_lobby", hostLobbyScreen);
    }
    
    private void removeAllScreens() {
        Collection<String> screenNames = nifty.getAllScreensName();
        for (String name : screenNames) {
            nifty.removeScreen(name);
        }
    }
    
}
